import 'package:backend.core/core/domain/entities/api/google_play/api_google_play_purchased_subscription_cancellation_survey_result.dart';
import 'package:backend.core/core/domain/entities/google_play/google_play_purchased_subscription_info_cancellation_survey_result.dart';
import 'package:backend.purchases/domain/helpers/api/google_play/create_api_google_play_purchased_subscription_cancellation_survey_reason_from_internal_one.dart';

abstract class CreateApiGooglePlayPurchasedSubscriptionCancellationSurveyResultFromInternalOne {
  ApiGooglePlayPurchasedSubscriptionCancellationSurveyResult call({
    required GooglePlayPurchasedSubscriptionInfoCancellationSurveyResult surveyResult,
  });
}

class CreateApiGooglePlayPurchasedSubscriptionCancellationSurveyResultFromInternalOneImpl
    implements CreateApiGooglePlayPurchasedSubscriptionCancellationSurveyResultFromInternalOne {
  const CreateApiGooglePlayPurchasedSubscriptionCancellationSurveyResultFromInternalOneImpl({
    required CreateApiGooglePlayPurchasedSubscriptionCancellationSurveyReasonFromInternalOne
        createApiGooglePlayPurchasedSubscriptionCancellationSurveyReasonFromInternalOne,
  }) : _createApiGooglePlayPurchasedSubscriptionCancellationSurveyReasonFromInternalOne =
            createApiGooglePlayPurchasedSubscriptionCancellationSurveyReasonFromInternalOne;

  final CreateApiGooglePlayPurchasedSubscriptionCancellationSurveyReasonFromInternalOne
      _createApiGooglePlayPurchasedSubscriptionCancellationSurveyReasonFromInternalOne;

  @override
  ApiGooglePlayPurchasedSubscriptionCancellationSurveyResult call({
    required GooglePlayPurchasedSubscriptionInfoCancellationSurveyResult surveyResult,
  }) {
    final reason = _createApiGooglePlayPurchasedSubscriptionCancellationSurveyReasonFromInternalOne(
      reason: surveyResult.reason,
    );

    return ApiGooglePlayPurchasedSubscriptionCancellationSurveyResult(
      reason: reason,
      customAnswer: surveyResult.customAnswer,
    );
  }
}
